package cn.edu.zufe.mjt.schedule;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

//TIP 要<b>运行</b>代码，请按 <shortcut actionId="Run"/> 或
// 点击装订区域中的 <icon src="AllIcons.Actions.Execute"/> 图标。
public class Main {
    public static void main(String[] args) throws InterruptedException {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss SSS");
        ScheduleService scheduleService = new ScheduleService();
        scheduleService.schedule(()-> {
            System.out.println(LocalDateTime.now().format(dateTimeFormatter) + ": 1");
        }, 100);
        Thread.sleep(1000);
        System.out.println("添加一个每200ms打印一个2的定时任务");
        scheduleService.schedule(()-> {
            System.out.println(LocalDateTime.now().format(dateTimeFormatter) + ": 2");
        }, 200);
    }
}